import RequestHttp from '@/utils/http'
import {
  ListResult,
  AdminItem,
  SearchParams,
  AdminIdParams,
  AdminParams,
  AdminStateParams,
  ResetPasswordParams,
  PersonalParams,
  PersonalPasswordParams,
} from './model/adminModel'

enum Api {
  index = '/api/sysAdmin/index',
  store = '/api/sysAdmin/store',
  show = '/api/sysAdmin/show',
  update = '/api/sysAdmin/update',
  state = '/api/sysAdmin/state',
  destroy = '/api/sysAdmin/destroy',
  resetPassword = '/api/sysAdmin/restPassword',
  updateParsonal = '/api/sysAdmin/updatePersonal',
  updateParsonalPassword = '/api/sysAdmin/updatePersonalPassword',
}

export const getList = (params?: SearchParams) => {
  return RequestHttp.get<ListResult>(Api.index, params)
}

export const store = (params: AdminParams) => {
  return RequestHttp.post<boolean>(Api.store, params)
}

export const show = (params: AdminIdParams) => {
  return RequestHttp.get<AdminItem>(Api.show, params)
}

export const update = (params: AdminParams) => {
  return RequestHttp.put<boolean>(Api.update, params)
}

export const state = (params: AdminStateParams) => {
  return RequestHttp.put<boolean>(Api.state, params)
}

export const destroy = (params: AdminIdParams) => {
  return RequestHttp.delete<boolean>(Api.destroy, params)
}

export const resetPassword = (params: ResetPasswordParams) => {
  return RequestHttp.put<boolean>(Api.resetPassword, params)
}

export const updateParsonal = (params: PersonalParams) => {
  return RequestHttp.put<boolean>(Api.updateParsonal, params)
}

export const updateParsonalPassword = (params: PersonalPasswordParams) => {
  return RequestHttp.put<boolean>(Api.updateParsonalPassword, params)
}
